<template>
  <div>
    <el-tabs v-model="activeName" @tab-click="handleClick">
      <el-tab-pane label="专题赛事" name="first">
        <div style="margin:2% 0;display: inline-block;">
          <span>赛事ID:</span>
          <el-input
            style="width: 150px;"
            @keydown.enter.native="select"
            clearable
            placeholder="请输入赛事ID"
            v-model="searchId"
          ></el-input>&nbsp;&nbsp;&nbsp;&nbsp;
          <span>游戏分类:</span>
          <el-select
            v-model="gameType"
            placeholder="请选择类型"
            style="width:150px;"
            @change="selectTrigger()"
          >
            <el-option v-for="item in gameTypeIds" :key="item.value" :label="item.label" :value="item.value">
            </el-option>
          </el-select>&nbsp;&nbsp;&nbsp;&nbsp;
          <!-- <span>赛事分类:</span>
          <el-select
            v-model="eventTypeId"
            placeholder="请选择类型"
            style="width:150px;"
            @change="selectTrigger()"
          >
            <el-option
              v-for="item in eventTypeIds"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            ></el-option>
          </el-select>&nbsp;&nbsp;&nbsp;&nbsp; -->
          <span>比赛状态:</span>
          <el-select
            v-model="eventStatus"
            placeholder="请选择类型"
            style="width:150px;"
            @change="selectTrigger()"
          >
            <el-option
              v-for="item in eventStatusnum"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            ></el-option>
          </el-select>
        </div>
        <div style="display: inline-block;">
          <el-button
            style="margin-left:15px;"
            size="mini"
            type="primary"
            icon="document"
            @click="select"
          >查询</el-button>
          <el-button
            style="margin-left:15px;"
            size="mini"
            type="primary"
            icon="document"
            @click="cleans"
          >重置</el-button>
          <el-button
            style="margin-left:15px;"
            size="mini"
            type="primary"
            icon="document"
            @click="refresh"
          >刷新</el-button>
          <el-button
            size="mini"
            style="margin-left: 10px;"
            :disabled="!isAuth('competition:add')"
            type="primary"
            icon="document"
            @click="addcompet"
          >添加赛事</el-button>
        </div>
        <el-table v-loading="tableDataLoading" :data="tableData.content">
          <el-table-column fixed prop="id" label="编号"></el-table-column>
          <el-table-column fixed prop="coverImg" label="封面图" width="120">
            <template slot-scope="scope">
              <div v-if="scope.row.coverImg == '' || scope.row.coverImg == null">
                <img src="~@/assets/img/avatar.png" alt width="60" height="60" />
              </div>
              <div v-else>
                <img :src="scope.row.coverImg" alt width="60" height="60" />
              </div>
            </template>
          </el-table-column>
          <el-table-column prop="settleImg" label="比赛结果图" width="120">
            <template slot-scope="scope">
              <div v-if="scope.row.settleImg == '' || scope.row.settleImg == null">暂无</div>
              <div v-else>
                <img :src="scope.row.settleImg" alt width="120" height="60" />
              </div>
            </template>
          </el-table-column>
          <el-table-column prop="gameTypeName" label="游戏分类">
            <template slot-scope="scope">
              <span
                style="color: #f56c6c;"
              >{{ scope.row.gameTypeId === 1 || scope.row.gameTypeId === 18 ? scope.row.gameTypeName : '未设置' }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="eventTypeName" label="赛事分类" width="150">
            <template slot-scope="scope">
              <span
                style="color: #f56c6c;"
              >{{ scope.row.eventTypeName ? scope.row.eventTypeName : '未设置' }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="roomNumber" label="房间号	" width="150">
            <template slot-scope="scope">
              <span>{{ scope.row.roomNumber ? scope.row.roomNumber : '暂无房间' }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="title" label="赛事标题"></el-table-column>
          <el-table-column prop="area" label="区域">
            <template slot-scope="scope">
              <span v-if="scope.row.area == 1">微信区</span>
              <span v-if="scope.row.area == 2">QQ区</span>
            </template>
          </el-table-column>
          <el-table-column prop="tag" label="标签"></el-table-column>
          <el-table-column prop="entryMoney" label="报名费"></el-table-column>
          <el-table-column prop="needNumber" label="预计报名人数" width="150"></el-table-column>
          <el-table-column prop="applyNumber" label="报名人数"></el-table-column>
          <el-table-column prop="entryTime" label="报名时间" width="160"></el-table-column>
          <el-table-column prop="startTime" label="开始时间" width="160"></el-table-column>
          <el-table-column fixed="right" prop="status " label="报名状态">
            <template slot-scope="scope">
              <el-switch
                v-model="scope.row.status"
                @change="change(scope.row.status, scope.row.id)"
                :active-value="openValue"
                :inactive-value="closeValue"
                active-color="#13ce66"
                inactive-color="#ff4949"
              ></el-switch>
            </template>
          </el-table-column>
          <el-table-column fixed="right" prop="eventStatus" label="比赛状态">
            <template slot-scope="scope">
              <span
                v-if="scope.row.eventStatus == 1 || scope.row.eventStatus == 2 || scope.row.eventStatus == 6 || scope.row.eventStatus == 7"
                :disabled="!isAuth('competition:begin')"
                @click="linkselect(scope.row)"
                style="background: #3E8EF7;height: 28px;line-height: 28px;width:60px;text-align: center; display: block;border-radius:4px;font-size: 12px; color:#FFFFFF;cursor: pointer;"
              >设置开始</span>
              <span
                v-if="scope.row.eventStatus == 1 || scope.row.eventStatus == 2 || scope.row.eventStatus == 6 || scope.row.eventStatus == 7 || scope.row.eventStatus == 8 || scope.row.eventStatus == 9"
                :disabled="!isAuth('competition:over')"
                @click="concel(scope.row)"
                style="background: #3E8EF7;height: 28px;line-height: 28px;width:60px;text-align: center; display: block;  border-radius:4px;font-size: 12px; color:#FFFFFF;cursor: pointer;margin: 5px 0 0 0 ;"
              >取消比赛</span>
              <span
                v-if="scope.row.eventStatus == 8 || scope.row.eventStatus == 9"
                :disabled="!isAuth('competition:cancel')"
                @click="finish(scope.row)"
                style="background: #f56c6c;height: 28px;line-height: 28px;width:60px;text-align: center; display: block;  border-radius:4px;font-size: 12px; color:#FFFFFF;cursor: pointer;margin: 5px 0 0 0;"
              >结束比赛</span>
              <span v-if="scope.row.eventStatus == 3">已结束 {{ scope.row.endTime }}</span>
              <span
                v-if="scope.row.eventStatus == 4 || scope.row.eventStatus == 5"
              >已取消 {{ scope.row.endTime }}</span>
            </template>
          </el-table-column>
          <el-table-column label="操作" fixed="right" width="120">
            <template slot-scope="scope">
              <!-- <el-button
						  size="mini"
						  type="primary"
							v-if="scope.row.eventStatus == 2"
						  @click="compileroom(scope.row)">修改房间
              </el-button>-->
              <el-button
                size="mini"
                type="primary"
                v-if="scope.row.eventStatus == 1 || scope.row.eventStatus == 2 || scope.row.eventStatus == 6 || scope.row.eventStatus == 7 || scope.row.eventStatus == 8 || scope.row.eventStatus == 9"
                :disabled="!isAuth('competition:update')"
                @click="compile(scope.row)"
              >编辑赛事</el-button>
              <el-button
                :disabled="!isAuth('competition:delete')"
                size="mini"
                type="danger"
                v-if="scope.row.eventStatus == 3 || scope.row.eventStatus == 4 || scope.row.eventStatus == 5"
                @click="deleteuser(scope.row)"
              >删除赛事</el-button>
              <!-- <el-button
							size="mini"
							type="primary"
							v-if="scope.row.eventStatus == 3"
							@click="standing(scope.row)">赛事战绩
              </el-button>-->
              <el-button
                size="mini"
                type="primary"
                v-if="scope.row.eventStatus == 3 || scope.row.eventStatus == 4 || scope.row.eventStatus == 5"
                @click="accountSelect(scope.row)"
              >赛事结算</el-button>
              <el-button
                size="mini"
                type="primary"
                v-if="scope.row.eventStatus == 1 || scope.row.eventStatus == 2 || scope.row.eventStatus == 6 || scope.row.eventStatus == 7 || scope.row.eventStatus == 8 || scope.row.eventStatus == 9"
                @click="applySelect(scope.row)"
              >赛事报名</el-button>
              <el-button
                size="mini"
                type="primary"
                v-if="scope.row.eventStatus == 1 || scope.row.eventStatus == 2 || scope.row.eventStatus == 6 || scope.row.eventStatus == 7 || scope.row.eventStatus == 8 || scope.row.eventStatus == 9"
                @click="virtualSelect(scope.row)"
              >用户报名</el-button>
            </template>
          </el-table-column>
        </el-table>
        <div style="text-align: center;margin-top: 10px;">
          <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :page-sizes="[5, 10, 15, 20]"
            :page-size="size"
            :current-page="page"
            layout="total,sizes, prev, pager, next"
            :total="tableData.totalElements"
          ></el-pagination>
        </div>
      </el-tab-pane>
      <el-tab-pane label="日常赛事" name="bouth">
        <div style="margin:2% 0;display: inline-block;">
          <span>比赛状态:</span>
          <el-select
            v-model="eventStatus"
            placeholder="请选择类型"
            style="width:150px;"
            @change="selectTrigger()"
          >
            <el-option
              v-for="item in eventStatusnum"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            ></el-option>
          </el-select>
        </div>
        <div style="display: inline-block;">
          <el-button
            style="margin-left:15px;"
            size="mini"
            type="primary"
            icon="document"
            @click="select"
          >查询</el-button>
          <el-button
            style="margin-left:15px;"
            size="mini"
            type="primary"
            icon="document"
            @click="cleans"
          >重置</el-button>
          <el-button
            style="margin-left:15px;"
            size="mini"
            type="primary"
            icon="document"
            @click="refresh"
          >刷新</el-button>
        </div>
        <el-table v-loading="tableDataLoading" :data="tableData.content">
          <el-table-column fixed prop="id" label="编号" width="80"></el-table-column>
          <el-table-column fixed prop="userName" label="创建人">
            <template slot-scope="scope">
              <span
                style="color: #4f9dec;cursor: pointer;"
                @click="updates(scope.row)"
              >{{ scope.row.userName ? scope.row.userName : '未设置' }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="settleImg" label="比赛结果图" width="120">
            <template slot-scope="scope">
              <div v-if="scope.row.settleImg == '' || scope.row.settleImg == null">暂无</div>
              <div v-else>
                <img :src="scope.row.settleImg" alt width="120" height="60" />
              </div>
            </template>
          </el-table-column>
          <el-table-column prop="title" label="赛事标题"></el-table-column>
          <el-table-column prop="area" label="区域">
            <template slot-scope="scope">
              <span v-if="scope.row.area == 1">微信区</span>
              <span v-if="scope.row.area == 2">QQ区</span>
            </template>
          </el-table-column>
          <el-table-column prop="tag" label="标签"></el-table-column>
          <el-table-column prop="entryMoney" label="报名费"></el-table-column>
          <el-table-column prop="needNumber" label="预计报名人数" width="150"></el-table-column>
          <el-table-column prop="applyNumber" label="报名人数"></el-table-column>
          <el-table-column prop="createTime" label="创建时间" width="160"></el-table-column>
          <el-table-column prop="entryTime" label="报名时间" width="160"></el-table-column>
          <el-table-column prop="startTime" label="开始时间" width="160"></el-table-column>
          <el-table-column fixed="right" prop="status " label="报名状态">
            <template slot-scope="scope">
              <el-switch
                v-model="scope.row.status"
                @change="change(scope.row.status, scope.row.id)"
                :active-value="openValue"
                :inactive-value="closeValue"
                active-color="#13ce66"
                inactive-color="#ff4949"
              ></el-switch>
            </template>
          </el-table-column>
          <el-table-column fixed="right" prop="eventStatus" label="比赛状态">
            <template slot-scope="scope">
              <span
                v-if="scope.row.eventStatus == 1 || scope.row.eventStatus == 2 || scope.row.eventStatus == 6 || scope.row.eventStatus == 7 || scope.row.eventStatus == 9"
                :disabled="!isAuth('competition:begin')"
                @click="linkselect(scope.row)"
                style="background: #3E8EF7;height: 28px;line-height: 28px;width:60px;text-align: center; display: block;border-radius:4px;font-size: 12px; color:#FFFFFF;cursor: pointer;"
              >设置开始</span>
              <span
                v-if="scope.row.eventStatus == 1 || scope.row.eventStatus == 2 || scope.row.eventStatus == 6 || scope.row.eventStatus == 7 || scope.row.eventStatus == 8 || scope.row.eventStatus == 9"
                :disabled="!isAuth('competition:over')"
                @click="concel(scope.row)"
                style="background: #3E8EF7;height: 28px;line-height: 28px;width:60px;text-align: center; display: block;  border-radius:4px;font-size: 12px; color:#FFFFFF;cursor: pointer;margin: 5px 0 0 0 ;"
              >取消比赛</span>
              <span
                v-if="scope.row.eventStatus == 8"
                :disabled="!isAuth('competition:cancel')"
                @click="finish(scope.row)"
                style="background: #f56c6c;height: 28px;line-height: 28px;width:60px;text-align: center; display: block;  border-radius:4px;font-size: 12px; color:#FFFFFF;cursor: pointer;margin: 5px 0 0 0;"
              >结束比赛</span>
              <span v-if="scope.row.eventStatus == 3">已结束 {{ scope.row.endTime }}</span>
              <span
                v-if="scope.row.eventStatus == 4 || scope.row.eventStatus == 5"
              >已取消 {{ scope.row.endTime }}</span>
            </template>
          </el-table-column>
          <el-table-column label="操作" fixed="right" width="120">
            <template slot-scope="scope">
              <el-button
                size="mini"
                type="primary"
                v-if="scope.row.eventStatus == 8"
                @click="compileroom(scope.row)"
              >修改房间</el-button>
              <el-button
                size="mini"
                type="primary"
                v-if="scope.row.eventStatus == 1"
                :disabled="!isAuth('competition:update')"
                @click="compile(scope.row)"
              >编辑赛事</el-button>
              <el-button
                :disabled="!isAuth('competition:delete')"
                size="mini"
                type="danger"
                v-if="scope.row.eventStatus == 3 || scope.row.eventStatus == 4"
                @click="deleteuser(scope.row)"
              >删除赛事</el-button>
              <el-button
                size="mini"
                type="primary"
                v-if="scope.row.eventStatus == 3"
                @click="standing(scope.row)"
              >赛事战绩</el-button>
              <el-button size="mini" type="primary" @click="accountSelect(scope.row)">赛事结算</el-button>
              <el-button size="mini" type="primary" @click="applySelect(scope.row)">赛事报名</el-button>
              <el-button
                size="mini"
                type="primary"
                v-if="scope.row.eventStatus == 1"
                @click="virtualSelect(scope.row)"
              >用户报名</el-button>
            </template>
          </el-table-column>
        </el-table>
        <div style="text-align: center;margin-top: 10px;">
          <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :page-sizes="[5, 10, 15, 20]"
            :page-size="size"
            :current-page="page"
            layout="total,sizes, prev, pager, next"
            :total="tableData.totalElements"
          ></el-pagination>
        </div>
      </el-tab-pane>
    </el-tabs>
    <!-- 房间链接 -->
    <el-dialog title="进入房间方式" :visible.sync="dialogFormVisible" center>
      <div style="margin-bottom: 10px;">
        <span
          style="width: 200px;display: inline-block;text-align: right;position: relative;top: -65px;"
        >房间链接：</span>
        <el-input
          style="width:50%;"
          type="textarea"
          :rows="4"
          v-model="roomUrl"
          placeholder="房间链接请以http开头"
        ></el-input>
      </div>
      <div style="margin-bottom: 10px;">
        <span style="width: 200px;display: inline-block;text-align: right;">房间号：</span>
        <el-input style="width:50%;" v-model="roomNumber" placeholder="请输入房间号"></el-input>
      </div>
      <div style="margin-bottom: 10px;display:flex;margin-left: 2px;">
        <span style="width: 200px;text-align: right;">房间二维码：</span>
        <div
          style=" width:148px;height:148px;border: 1px dashed #c0ccda;border-radius: 6px;text-align: center;line-height: 148px;"
        >
          <el-upload
            class="avatar-uploader"
            v-model="roomImg"
            action="https://admin.koudaidj.com/game/alioss/upload"
            :show-file-list="false"
            :on-success="handleAvatarSuccess1"
          >
            <img
              v-if="roomImg"
              :src="roomImg"
              class="avatar"
              style="border-radius: 6px;width: 140px;height: 140px;"
            />
            <i v-else class="el-icon-plus avatar-uploader-icon"></i>
          </el-upload>
        </div>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="cashNoticeTo()">确 定</el-button>
      </div>
    </el-dialog>
    <!-- 修改房间信息 -->
    <el-dialog title="修改房间信息" :visible.sync="dialogFormVisible2" center>
      <el-form :model="form">
        <el-form-item label="房间链接：" :label-width="formLabelWidth">
          <el-input
            v-model="form.roomUrl"
            type="textarea"
            :rows="4"
            style="width:65%;"
            placeholder="请输入房间链接"
          ></el-input>
        </el-form-item>
        <el-form-item label="房间号：" :label-width="formLabelWidth">
          <el-input v-model="form.roomNumber" style="width:65%;" placeholder="请输入房间号"></el-input>
        </el-form-item>
        <el-form-item label="房间二维码：" :label-width="formLabelWidth">
          <div
            style=" width:140px;height:140px;border: 1px dashed #c0ccda;border-radius: 6px;text-align: center;line-height: 148px;"
          >
            <el-upload
              class="avatar-uploader"
              v-model="form.roomImg"
              action="https://admin.koudaidj.com/game/alioss/upload"
              :show-file-list="false"
              :on-success="handleAvatarSuccess2"
            >
              <img
                v-if="form.roomImg"
                :src="form.roomImg"
                class="avatar"
                style="border-radius: 6px;width: 148px;height: 148px;"
              />
              <i v-else class="el-icon-plus avatar-uploader-icon"></i>
            </el-upload>
          </div>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible2 = false">取 消</el-button>
        <el-button type="primary" @click="roomNoticeTo()">确 定</el-button>
      </div>
    </el-dialog>
    <!-- 上传结束图 -->
    <el-dialog title="上传比赛结果图" :visible.sync="dialogFormVisible1" center>
      <div style="margin-bottom: 10px;display:flex;">
        <span style="width: 200px;text-align: right;">比赛结果图：</span>
        <div
          style=" width:148px;height:148px;border: 1px dashed #c0ccda;border-radius: 6px;text-align: center;line-height: 148px;"
        >
          <el-upload
            class="avatar-uploader"
            v-model="settleImg"
            action="https://admin.koudaidj.com/game/alioss/upload"
            :show-file-list="false"
            :on-success="handleAvatarSuccess"
          >
            <img
              v-if="settleImg"
              :src="settleImg"
              class="avatar"
              style="border-radius: 6px;width: 140px;height: 140px;"
            />
            <i v-else class="el-icon-plus avatar-uploader-icon"></i>
          </el-upload>
        </div>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible1 = false">取 消</el-button>
        <el-button type="primary" @click="awardsNoticeTo()">确 定</el-button>
      </div>
    </el-dialog>
    <!-- 虚拟报名 -->
    <el-dialog title="用户列表" :visible.sync="dialogFormVisible3" center>
      <div>
        <el-button
          style="float: right;margin-bottom: 15px;"
          :disabled="checkBoxData.length <= 0"
          size="mini"
          type="primary"
          icon="document"
          @click="batchApply()"
        >批量报名</el-button>
      </div>
      <el-table v-loading="tableDataLoading" @selection-change="changeFun" :data="userdata.content">
        <el-table-column type="selection" fixed></el-table-column>
        <el-table-column prop="userId" label="编号"></el-table-column>
        <el-table-column prop="headImg" label="头像" width="120">
          <template slot-scope="scope">
            <div v-if="scope.row.headImg == '' || scope.row.headImg == null">
              <img src="~@/assets/img/avatar.png" alt width="60" height="60" />
            </div>
            <div v-else>
              <img :src="scope.row.headImg" alt width="60" height="60" />
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="userName" label="登录名">
          <template slot-scope="scope">
            <span>{{ scope.row.userName ? scope.row.userName : '未设置' }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="relationId" label="会员编号">
          <template slot-scope="scope">
            <span>{{ scope.row.isInvitation === 0 ? '未授权' : scope.row.relationId ? scope.row.relationId : '未绑定' }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="invitation" label="邀请人" width="120">
          <template slot-scope="scope">
            <span>{{ scope.row.invitation ? scope.row.invitation : '未设置' }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="phone" label="手机号" width="150">
          <template slot-scope="scope">
            <span>{{ scope.row.phone ? scope.row.phone : '未绑定' }}</span>
          </template>
        </el-table-column>
        <el-table-column label="操作" fixed="right" width="100">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="primary"
              @click="apply(scope.row)"
              v-if="scope.row.isVirtualUser == 'true'"
            >报名</el-button>
            <span v-else>已报名</span>
          </template>
        </el-table-column>
      </el-table>
      <div style="text-align: center;margin-top: 10px;">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :page-sizes="[5, 10, 15, 20]"
          :page-size="size"
          :current-page="page"
          layout="total,sizes, prev, pager, next"
          :total="userdata.totalElements"
        ></el-pagination>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  data() {
    return {
      gameType: 1,
      openValue: 1,
      closeValue: 2,
      size: 10,
      page: 1,
      id: '',
      gameTypeId: '',
      title: '',
      searchId: '',
      roomUrl: '',
      roomNumber: '',
      roomImg: '',
      settleImg: '',
      finishid: '',
      userdata: [],
      gameTypeIds:[],
      eventStatus: 0,
      ispk: 'false',
      eventStatusnum: [
        {
          label: '全部',
          value: 0
        },
        {
          label: '未开始',
          value: 1
        },
        {
          label: '进行中',
          value: 2
        },
        {
          label: '已结束',
          value: 3
        },
        {
          label: '已解散',
          value: 4
        }
      ],
      form: {
        id: '',
        roomUrl: '',
        roomNumber: '',
        roomImg: ''
      },
      checkBoxData: [],//多选框选择的值
      formLabelWidth: '200px',
      eventTypeId: 41,
      eventTypeIds: [],
      activeName: 'first',
      tableDataLoading: true,
      dialogFormVisible: false,
      dialogFormVisible1: false,
      dialogFormVisible2: false,
      dialogFormVisible3: false,
      tableData: [],
    }
  },
  methods: {
    // 多选
    changeFun(val) {
      this.checkBoxData = val;
    },
    // 图标上传
    handleAvatarSuccess(file) {
      this.settleImg = file.data;
    },
    // 图标上传
    handleAvatarSuccess2(file) {
      this.form.roomImg = file.data;
    },
    // 图标上传
    handleAvatarSuccess1(file) {
      this.roomImg = file.data;
    },
    handleSizeChange(val) {
      this.size = val
      this.dataSelect()
    },
    handleCurrentChange(val) {
      this.page = val
      this.dataSelect()
    },
    handleClick(tab, event) {
      if (tab._props.label == '专题赛事') {
        this.ispk = 'false'
        this.dataSelect()
      }
      if (tab._props.label == '日常赛事') {
        this.ispk = 'true'
        this.dataSelect()
      }
    },
    // select自动选择
    selectTrigger() {
      this.dataSelect()
    },
    // 查询
    select() {
      this.page = 1
      this.size = 5
      this.dataSelect()
    },
    // 重置
    cleans() {
      this.searchId = ''
      this.gameTypeId = ''
      this.dataSelect()
    },
    // 刷新
    refresh() {
      this.page = 1
      this.size = 5
      this.dataSelect()
    },
    // 修改房间信息
    compileroom(row) {
      console.log(row)
      this.form.id = row.id
      this.form.roomUrl = row.roomUrl
      this.form.roomNumber = row.roomNumber
      this.form.roomImg = row.roomImg
      this.dialogFormVisible2 = true
    },
    roomNoticeTo() {
      if (this.form.roomUrl == '' && this.form.roomNumber == '' && this.form.roomImg == '') {
        this.$notify({
          title: '提示',
          duration: 1800,
          message: '请最少选择一种进入房间方式',
          type: 'warning'
        });
        return
      }
      this.$http({
        url: this.$http.adornUrl2('/gameEvent/roomUrl'),
        method: 'get',
        params: this.$http.adornParams({
          'id': this.form.id,
          'roomUrl': this.form.roomUrl,
          'roomNumber': this.form.roomNumber,
          'roomImg': this.form.roomImg
        })
      }).then(({ data }) => {
        if (data.status == 0) {
          this.$message({
            message: '修改成功',
            type: 'success',
            duration: 1500,
            onClose: () => {
              this.dataSelect()
              this.dialogFormVisible2 = false
            }
          })
        } else {
          this.$message({
            message: data.msg,
            type: 'error',
            duration: 1500,
            onClose: () => {
              this.dataSelect()
              this.dialogFormVisible2 = false
            }
          })
        }
      })
    },
    // 状态
    change(val, id) {
      this.$http({
        url: this.$http.adornUrl2('/gameEvent/updateStatus'),
        method: 'get',
        params: this.$http.adornParams({
          'id': id,
          'status': val
        })
      }).then(({ data }) => {
        this.$message({
          message: '操作成功',
          type: 'success',
          duration: 1500,
          onClose: () => {
            this.dataSelect()
          }
        })
      })
    },
    // 添加赛事
    addcompet() {
      this.$router.push({ path: '/addcompet' })
    },
    // 编辑赛事
    compile(rows) {
      this.$router.push({ path: '/admencompet', query: { id: rows.id } })
    },
    // 战绩
    standing(rows) {
      this.$router.push({ path: '/standings', query: { gameEventId: rows.id } })
    },
    //删除用赛事
    deleteuser(row) {
      if (row.applyNumber > 0) {
        this.$notify({
          title: '提示',
          duration: 1800,
          message: '已经有人报名，不能删除',
          type: 'warning'
        });
        return
      } else {
        this.$confirm(`确定删除此条信息?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$http({
            url: this.$http.adornUrl2('/gameEvent/delete'),
            method: 'get',
            params: this.$http.adornParams({
              'id': row.id
            })
          }).then(({ data }) => {
            this.$message({
              message: '删除成功',
              type: 'success',
              duration: 1500,
              onClose: () => {
                this.name = ''
                this.dataSelect()
              }
            })
          })
        }).catch(() => {
        })
      }
    },
    // 赛事结算
    accountSelect(row) {
      this.$router.push({ path: '/account', query: { gameTypeId: row.gameTypeId, gameEventId: row.id } })
    },
    // 赛事报名
    applySelect(row) {
      this.$router.push({ path: '/apply', query: { gameTypeId: row.gameTypeId, gameEventId: row.id } })
    },
    // 设置报名弹框
    linkselect(row) {
      this.dialogFormVisible = true
      this.id = row.id
    },
    // 设置报名
    cashNoticeTo() {
      if (this.roomUrl == '' && this.roomNumber == '' && this.roomImg == '') {
        this.$notify({
          title: '提示',
          duration: 1800,
          message: '请最少选择一种进入房间方式',
          type: 'warning'
        });
        return
      }
      this.$http({
        url: this.$http.adornUrl2('/gameEvent/roomUrl'),
        method: 'get',
        params: this.$http.adornParams({
          'id': this.id,
          'roomUrl': this.roomUrl,
          'roomNumber': this.roomNumber,
          'roomImg': this.roomImg
        })
      }).then(({ data }) => {
        this.$message({
          message: '操作成功',
          type: 'success',
          duration: 1500,
          onClose: () => {
            this.dataSelect()
            /* this.roomUrl = ''
            this.roomNumber = ''
            this.roomImg = '' */
            this.dialogFormVisible = false
          }
        })
      })
    },
    // 取消比赛
    concel(row) {
      this.$confirm(`确定要取消比赛?`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$http({
          url: this.$http.adornUrl2('/gameEvent/disEvent'),
          method: 'get',
          params: this.$http.adornParams({
            'id': row.id,
          })
        }).then(({ data }) => {
          if (data.status == 0) {
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {
                this.dataSelect()
              }
            })
          } else {
            this.$message({
              message: data.msg,
              type: 'error',
              duration: 1500,
              onClose: () => {
                this.dataSelect()
              }
            })
          }
        })
      })
    },
    // 设置结束
    finish(row) {
      this.dialogFormVisible1 = true
      this.finishid = row.id
    },
    awardsNoticeTo() {
      if (this.settleImg == '') {
        this.$notify({
          title: '提示',
          duration: 1800,
          message: '请上传比赛结果图',
          type: 'warning'
        });
        return
      } else {
        this.$confirm(`确定要结束比赛?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$http({
            url: this.$http.adornUrl2('/gameEvent/endEvent'),
            method: 'get',
            params: this.$http.adornParams({
              'id': this.finishid,
              'settleImg': this.settleImg
            })
          }).then(({ data }) => {
            if (data.status == 0) {
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
                onClose: () => {
                  this.settleImg = ''
                  this.dialogFormVisible1 = false
                  this.dataSelect()
                }
              })
            } else {
              this.$message({
                message: '未知错误',
                type: 'error',
                duration: 1500,
                onClose: () => {
                  this.dialogFormVisible1 = false
                  this.dataSelect()
                }
              })
            }

          })
        })
      }
    },
    // 详情跳转
    updates(row) {
      this.$router.push({
        path: '/userDetail',
        query: {
          userId: row.userId
        }
      })
    },
    // 虚拟报名
    virtualSelect(row) {
      this.tableDataLoading = true
      this.dialogFormVisible3 = true
      this.gameEventId = row.id
      this.userList()
    },
    // 用户列表
    userList() {
      let page = this.page - 1
      this.$http({
        url: this.$http.adornUrl2('/user/virtualUserList'),
        method: 'get',
        params: this.$http.adornParams({
          'page': page,
          'size': this.size,
          'gameEventId': this.gameEventId
        })
      }).then(({ data }) => {
        this.tableDataLoading = false
        let returnData = data.data
        this.userdata = returnData
      })
    },
    // 虚拟报名
    apply(row) {
      this.$http({
        url: this.$http.adornUrl2('/user/virtualUserApply'),
        method: 'get',
        params: this.$http.adornParams({
          'userId': row.userId,
          'gameEventId': this.gameEventId
        })
      }).then(({ data }) => {
        if (data.status == 0) {
          this.$message({
            message: '操作成功',
            type: 'success',
            duration: 1500,
            onClose: () => {
              this.userList()
            }
          })
        } else {
          this.$message({
            message: data.msg,
            type: 'error',
            duration: 1500,
            onClose: () => {
              this.userList()
            }
          })
        }
      })
    },
    // 批量报名
    batchApply(id) {
      var ids = id ? [id] : this.checkBoxData.map(item => {
        return item.userId
      })
      for (var i in ids) {
        this.$http({
          url: this.$http.adornUrl2(`/user/virtualUserApply?userId=${ids[i]}&gameEventId=${this.gameEventId}`),
          method: 'get',
          params: this.$http.adornParams({
          })
        }).then(({ data }) => {
          if (data.status == 0) {
            this.$message({
              message: '报名成功',
              type: 'success',
              duration: 1500,
              onClose: () => {
                this.userList()
              }
            })
          } else {
            this.$message({
              message: '报名失败',
              type: 'error',
              duration: 1500,
              onClose: () => {
                this.userList()
              }
            })
          }
        })
      }
    },
    // 获取游戏分类
    gameClass(){
    this.$http({
      url: this.$http.adornUrl2('/gameType/result'),
      method: 'get',
      params: this.$http.adornParams({
      })
    }).then(({data}) => {
      this.tableDataLoading = false
      let returnData = data.data
      this.gameTypeIds = returnData
    })
    },
    // 获取赛事分类
    competClass() {
      this.$http({
        url: this.$http.adornUrl2('/gameEventType/result'),
        method: 'get',
        params: this.$http.adornParams({
        })
      }).then(({ data }) => {
        this.tableDataLoading = false
        let returnData = data.data
        this.eventTypeIds = returnData
      })
    },
    // 获取数据列表
    dataSelect() {
      let page = this.page - 1
      this.tableDataLoading = true
      this.$http({
        url: this.$http.adornUrl2('/gameEvent/list'),
        method: 'get',
        params: this.$http.adornParams({

          'id': this.searchId,
          'page': page,
          'size': this.size,
          // 'title': this.title,
          'ispk': this.ispk,
          'gameTypeId': this.gameType,
          'eventStatus': this.eventStatus,
          'eventTypeId': this.eventTypeId
        })
      }).then(({ data }) => {
        this.tableDataLoading = false
        let returnData = data.data
        this.tableData = returnData
        console.log(this.tableData)
      })
    }
  },
  mounted() {
    this.dataSelect()
    this.gameClass()
    this.competClass()
  }
}
</script>

<style scoped="scoped">
.el-button + .el-button {
  margin-left: 0 !important;
  margin-top: 5px !important;
}
</style>
